<?php
class StartupModel extends Model {
	public function get_primary_key() {
		return $this->primary_key = 'id'; //设置主键
	}
	public function get_fields() {
		return $this->get_table_fields();
	}

	/**
	 * 更新引导页面图片
	 * @param $img
	 * @return bool
	 */
	public function updateStartup($img)
	{
		try {
			$time = time();
			$param=array(
				'img'=>$img,
				'update_time'=>$time,
			);
			$this->db->update('ca_start_up', $param);
			$result = $this->db->affected_rows();
			if(empty($result)){
				return false;
			}
		} catch (Exception $e) {
			log_message('error',  $e->getMessage());
		}
		return true;
	}

	/**
	 * 获取引导页图片
	 * @return mixed
	 */
	public function getStartup()
	{
		try {
			$query = $this->db->query('SELECT img FROM ca_start_up');
			$row = $query->row();
		} catch (Exception $e) {
			log_message('error',  $e->getMessage());
		}
		return $row;
	}
}